import com.myjob.BlogMain;
import com.myjob.entity.Comment;
import com.myjob.enums.RedisEnums;
import com.myjob.service.CommentService;
import com.myjob.utils.RedisUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;

/**
 * @author Chen Yuan
 * @create 2021-02-27  16:37
 */
@SpringBootTest(classes = {BlogMain.class})
public class test {
	@Autowired
	private CommentService commentService;
	@Autowired
	private RedisUtil redisUtil;
	@Test
	public void test(){
		List<List<Comment>> lists = commentService.selectComments("820076");
		for (List<Comment> list : lists) {
			for (Comment comment : list) {
				System.out.println(comment);
			}
		}
	}
	@Test
	public void redisTest(){
		Map<String, Integer> map = (Map<String, Integer>) redisUtil.get(RedisEnums.KEY_IN_REDIS.READ_NUM.getValue());

		System.out.println(map);

		Set<String> keySet = map.keySet();
		Iterator<String> iterator = keySet.iterator();
		while (iterator.hasNext()) {
			String key = iterator.next();
			System.out.println("["+key+", "+ map.get(key) +"]");
		}

	}
}
